import { _decorator, Component,Animation, EventKeyboard, Input, input, KeyCode, Node, RigidBody2D } from 'cc';
import { PlayerStateMachine } from './State/PlayerStateMachine';
import { ENTITY_STATE_ENUM, PARAMS_NAME_ENUM } from '../Enum';
import { InputManager } from '../Base/InputManager';
import { PhysicalSystemDetection } from './PhysicalSystemDetection';
import { PlayerDataWithDash } from './PlayerDataWithDash';
import { MapManager } from '../MergeCollider/MapManager';
const { ccclass, property } = _decorator;

@ccclass('PlayerManager')
export class PlayerManager extends Component {

    @property(PlayerDataWithDash)
    data: PlayerDataWithDash = null;
    
    @property(RigidBody2D)
    rb: RigidBody2D = null;

    @property({ type: PhysicalSystemDetection })
    groundCheck: PhysicalSystemDetection = null;

    @property({ type: PhysicalSystemDetection })
    rightWallCheck: PhysicalSystemDetection = null;

    @property({ type: PhysicalSystemDetection })
    leftWallCheck: PhysicalSystemDetection = null;
    
    fsm: PlayerStateMachine;
    @property({ type: MapManager })
    mapMgr: MapManager;

    isInit = false;

    async start() {
        this.isInit = true;
        await this.init();
        InputManager.Instance.init();
        this.isInit = false;
    }
    async init() {
        await this.mapMgr.init(this.node)
        this.fsm = this.addComponent(PlayerStateMachine)
        await this.fsm.init(this)
        
    }

}


